home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9502 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Calling a function by reference?!
  5. Date: 11 Mar 1996 15:39:19 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4i1hf7$k3q@sparcserver.lrz-muenchen.de>
  9. References: <ga16wMlyZAQF088yn@ime.usp.br>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. rbrito@ime.usp.br (Rogerio Brito) writes:
  13.  
  14. >        How  do I declare a function (say, foo) that receives two
  15. >        strings and does modifications to both?
  16.  
  17. >        Is there a better way than:
  18. >        
  19. >        void foo(char **argument1, char **argument2);
  20.  
  21. It depends on what kind of modifications your function will do
  22. to those stirngs. If the pointer whose address you pass to foo()
  23. will point to a different location in memory when your function
  24. returns, passing a pointer to a pointer is a good idea. If you
  25. want to change all uppercase 'A' character to 'Z', passing the
  26. pointer to the first character is enough, because you will not
  27. modify the _location_ that the pointer points to, only the
  28. _contents_ of the string that the pointer points to.
  29.  
  30. >        ?? (It seems to be a dirty way... :( )
  31.  
  32. I'm afraid I don't understand that remark. 
  33.  
  34. Kurt
  35. --
  36. | Kurt Watzka                             Phone : +49-89-2180-6254
  37. | watzka@stat.uni-muenchen.de
  38. | ua302aa@sunmail.lrz-muenchen.de
  39.